//
//  AppDelegate.m
//  W_0821
//
//  Created by 闫潇 on 14-8-21.
//  Copyright (c) 2014年 xian. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    UISlider * slider = [[UISlider alloc]initWithFrame:CGRectMake(60, 35,200 , 30)];
    [slider setValue:0.7];
    [self.window addSubview:slider];
    [slider addTarget:self action:@selector(doSlider:) forControlEvents:UIControlEventValueChanged];
    
    UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(130, 420, 60, 40)];
    [button setTitle:@"开/关" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
    [button setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1]];
    [self.window addSubview:button];
    
    UIImageView * imageview = [[UIImageView alloc]initWithFrame:CGRectMake(0, 80, 320, 320)];
//    UIImage 只是一个用于加载图片的类，本质存储的时二进制信息
    UIImage * image = [UIImage imageNamed:@"car1.tiff"];
    [imageview setImage:image];
//    imageView负责将image中的二进制信息渲染到屏幕
    NSMutableArray * images = [NSMutableArray array];
    for (int i=1; i<7; i++)
    {
        NSString * imageStr = [NSString stringWithFormat:@"car%d.tiff",i];
        UIImage * i =[UIImage imageNamed:imageStr];
        [images addObject:i];
    }
//    设置imageview的图片集合
    [imageview setAnimationImages:images];
//    设置动画持续的时间
//    设置动画的持续时间，
    double a= slider.value;
    [imageview setAnimationDuration:a];
//    开始动画
    [imageview startAnimating];
    [self.window addSubview:imageview];
    
    return YES;
}
-(void)doSlider:(UISlider*)slider
{
    NSLog(@"%f",slider.value);
    _progress.progress=slider.value;
}



@end
